package jy.model;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * User entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "user", catalog = "waimai")
public class User implements java.io.Serializable {

	// Fields

	private Integer id;
	private String pname;
	private String mail;
	private String password;
	private String tel;
	private String city;
	private String area;
	private Integer type;
	private Set<Order> ordersForRuId = new HashSet<Order>(0);
	private Set<Order> ordersForOuId = new HashSet<Order>(0);
	private Set<Store> stores = new HashSet<Store>(0);
	private Set<Address> addresses = new HashSet<Address>(0);

	// Constructors

	/** default constructor */
	public User() {
	}

	/** minimal constructor */
	public User(String pname, String mail, String password, String tel,
			String city, String area, Integer type) {
		this.pname = pname;
		this.mail = mail;
		this.password = password;
		this.tel = tel;
		this.city = city;
		this.area = area;
		this.type = type;
	}

	/** full constructor */
	public User(String pname, String mail, String password, String tel,
			String city, String area, Integer type, Set<Order> ordersForRuId,
			Set<Order> ordersForOuId, Set<Store> stores, Set<Address> addresses) {
		this.pname = pname;
		this.mail = mail;
		this.password = password;
		this.tel = tel;
		this.city = city;
		this.area = area;
		this.type = type;
		this.ordersForRuId = ordersForRuId;
		this.ordersForOuId = ordersForOuId;
		this.stores = stores;
		this.addresses = addresses;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "pname", nullable = false, length = 40)
	public String getPname() {
		return this.pname;
	}

	public void setPname(String pname) {
		this.pname = pname;
	}

	@Column(name = "mail", nullable = false, length = 40)
	public String getMail() {
		return this.mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	@Column(name = "password", nullable = false, length = 40)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "tel", nullable = false, length = 20)
	public String getTel() {
		return this.tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	@Column(name = "city", nullable = false, length = 40)
	public String getCity() {
		return this.city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	@Column(name = "area", nullable = false, length = 40)
	public String getArea() {
		return this.area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	@Column(name = "type", nullable = false)
	public Integer getType() {
		return this.type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "userByRuId")
	public Set<Order> getOrdersForRuId() {
		return this.ordersForRuId;
	}

	public void setOrdersForRuId(Set<Order> ordersForRuId) {
		this.ordersForRuId = ordersForRuId;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "userByOuId")
	public Set<Order> getOrdersForOuId() {
		return this.ordersForOuId;
	}

	public void setOrdersForOuId(Set<Order> ordersForOuId) {
		this.ordersForOuId = ordersForOuId;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Store> getStores() {
		return this.stores;
	}

	public void setStores(Set<Store> stores) {
		this.stores = stores;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Address> getAddresses() {
		return this.addresses;
	}

	public void setAddresses(Set<Address> addresses) {
		this.addresses = addresses;
	}

}